//
//  MLASettingsVC.m
//  MagicLampApp
//
//  Created by Zheng on 2018/12/19.
//  Copyright © 2018 zheng.magic.lamp.app. All rights reserved.
//

#import "MLASettingsVC.h"
#import "MLAChangePasswordVC.h"
#import "MLAAboutUsVC.h"
#import "MLALoginVC.h"
#import "MLABaseNavController.h"
#import "MLAStoreHomeVC.h"
#import "MLAShopDetailInfoVC.h"

@interface MLASettingsVC ()

@end

@implementation MLASettingsVC

- (void)viewDidLoad {
    [super viewDidLoad];

    [self configTitle:@"设置"];
    
    self.titlesArr = @[@"关于我们",@"密码管理",@"店铺信息"];
    [self.tableView reloadData];
    
    UIButton *exitBtn = [self getCommitButtonWithTitle:@"退出登录"];
    [exitBtn addTarget:self action:@selector(exitBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:exitBtn];
    [exitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-20);
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(40);
    }];
    

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [super tableView:tableView didSelectRowAtIndexPath:indexPath];
    if (indexPath.row == 0) {
        CX_Log(@"关于我们");
        MLAAboutUsVC *aboutUsVC = [[MLAAboutUsVC alloc] init];
        [self.navigationController pushViewController:aboutUsVC animated:YES];
    } else if (indexPath.row == 1) {
        CX_Log(@"密码管理");
        MLAChangePasswordVC *changePasswordVC = [[MLAChangePasswordVC alloc] init];
        [self.navigationController pushViewController:changePasswordVC animated:YES];
    } else if (indexPath.row == 2) {
//        MLAStoreHomeVC *shVC = [[MLAStoreHomeVC alloc] init];
//        [self.navigationController pushViewController:shVC animated:YES];
        MLAShopDetailInfoVC *sdiVC = [[MLAShopDetailInfoVC alloc] init];
        [self.navigationController pushViewController:sdiVC animated:YES];
    }
}

- (void)exitBtnAction {
    [CX_GetUserDefaults() removeObjectForKey:kAccessToken];
    MLALoginVC *loginVC = [[MLALoginVC alloc] init];
    MLABaseNavController *rootVC = [[MLABaseNavController alloc] initWithRootViewController:loginVC];
    CX_GetKeyWindow().rootViewController = rootVC;

}

@end
